import { Select } from "antd";
import { useRequest } from "ahooks";
import { evaluationProjectV1ControllerAll } from "@/services/auto/evaluationProject";

export default function EvaluationProjectSelect({
  value,
  onChange,
                                                  placeholder = '请选择测试项',
                                         }:{
    value?: Value;
    onChange?: (val?: Value)=>void;
    placeholder?: string;
}){
    const {data ,loading  } = useRequest(()=>{
      return evaluationProjectV1ControllerAll()
    }, {
    });

    return <Select
      mode="multiple"
      value={value}
      onChange={onChange}
      options={data?.map(item=>{
      return {
        label: item.name,
        value: item.uuid,
      }
    })}
      loading={loading}
      placeholder={placeholder}
    />
}

export type Value = string[];
